from kivymd.uix.datatables import MDDataTable
from kivy.metrics import dp


class EntriesViews:
    def __init__(self, entries: list = None):
        if entries is None:
            entries = []
        self.entries = entries

    def view(self):
        data_tables = MDDataTable(
            size_hint=(1, 1),
            rows_num=10**6,
            column_data=[
                ("ID", dp(10)),
                ("Номер пары", dp(25)),
                ("Номер компьютера", dp(25)),
                ("Фамилия студента", dp(25)),
                ("Дата", dp(20)),
                ("Фамилия лаборанта", dp(25)),
                ("Название кабинета", dp(20)),

            ],
            row_data=[
                i.to_row() for i in self.entries
            ],
        )

        return data_tables



class DirectionsViews:
    def __init__(self, directions: list = None):
        self.directions = directions

    def view(self):
        data_tables = MDDataTable(
            size_hint=(1, 1),
            rows_num=10**6,
            column_data=[
                ("ID", dp(10)),
                ("Название направления", dp(35)),

            ],
            row_data=[
                i.to_row() for i in self.directions
            ],
        )

        return data_tables


class LaborantsViews:
    def __init__(self, laborants: list = None):
        self.laborants = laborants

    def view(self):

        data_tables = MDDataTable(
            size_hint=(1, 1),
            rows_num=10**6,
            column_data=[
                ("ID", dp(10)),
                ("Фамилия лаборанта", dp(35)),

            ],
            row_data=[
                i.to_row() for i in self.laborants
            ],
        )

        return data_tables

    def view_itog(self):

        data_tables = MDDataTable(
            size_hint=(1, 1),
            rows_num=10 ** 6,
            column_data=[
                ("Фамилия", dp(20)),
                ("Всего пар", dp(20))
            ],
            row_data=[
                (str(i.second_name), str(0)) for i in self.laborants
            ],
        )

        return data_tables


class CabinetsViews:
    def __init__(self, cabinets: list = None):
        self.cabinets = cabinets

    def view(self):

        data_tables = MDDataTable(
            size_hint=(1, 1),
            rows_num=10**6,
            column_data=[
                ("ID", dp(10)),
                ("Название кабинета", dp(35)),

            ],
            row_data=[
                i.to_row() for i in self.cabinets
            ],
        )

        return data_tables

    def view_itog(self):

        data_tables = MDDataTable(
            size_hint=(1, 1),
            rows_num=10 ** 6,
            column_data=[
                ("Название", dp(20)),
                ("Всего пар", dp(20))
            ],
            row_data=[
                (str(i.name), str(0)) for i in self.cabinets
            ],
        )

        return data_tables

class StudentsViews:
    def __init__(self, students: list = None):
        self.students = students

    def view(self):

        data_tables = MDDataTable(
            size_hint=(1, 1),
            rows_num=10**6,
            column_data=[
                ("ID", dp(10)),
                ("Фамилия студента", dp(35)),
                ("Название направления", dp(30))

            ],
            row_data=[
                i.to_row() for i in self.students
            ],
        )

        return data_tables

    def view_itog(self):

        data_tables = MDDataTable(
            size_hint=(1, 1),
            rows_num=10 ** 6,
            column_data=[
                ("Фамилия", dp(20)),
                ("Всего пар", dp(20))
            ],
            row_data=[
                (str(i.name), str(0)) for i in self.students
            ],
        )

        return data_tables


